﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBService;

public partial class administration_ManagePoster : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void SFindID_Click(object sender, EventArgs e)
    {
        int ID;
        if (int.TryParse(textid.Value, out ID))
        {
            BindGrid(ID);
        }
        else
            BindGrid(null);
        // var id = int.Parse(textid.Value);

    }

    private void BindGrid(int? ID)
    {
        ModelAdapter service = new ModelAdapter();
        PosterGridView.DataSource = service.GetPosterByID(ID);
        PosterGridView.DataBind();
    }

    protected void ReviewGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        ModelAdapter service = new ModelAdapter();
        var commandName = e.CommandName;
        var Id = int.Parse(e.CommandArgument.ToString());
        switch (commandName)
        {
            case "RestoreCommand":
                service.RestorePosterById(Id);
                break;
            case "DeleteCommand":
                service.RemovePosterById(Id);
                break;
            case "EditCommand":
                break;
            default:
                break;
        }
        BindGrid(null);
    }
}